package com.oracle.oa.action;

import java.util.List;
import java.util.Map;

import org.apache.struts2.interceptor.SessionAware;

import com.opensymphony.xwork2.ActionSupport;
import com.oracle.oa.biz.UserInfoBiz;
import com.oracle.oa.biz.impl.UserInfoBizImpl;
import com.oracle.oa.entity.Userinfo;

public class SelectToUserAction extends ActionSupport implements SessionAware {

	private String depart;//部门
	private long usid=0;//usid
	private String usname;//usname
	
	private String userresult;//返回的user的结果集
	
	Map<String, Object> session;
	
	UserInfoBiz ubiz;
	
	@Override
	public String execute() throws Exception {
		List<Userinfo> ulist = null;
		if(depart!=null && usid!=0 && usname!=null){
			ulist = ubiz.getBydepartAndUsernameandUserid(depart, usid, usname);
		}else if(depart!=null && usid!=0){
			ulist = ubiz.getBydepartAndUserid(depart, usid);
		}else if(depart!=null && usname!=null){
			ulist = ubiz.getBydepartAndUsername(depart, usname);
		}else if(usid!=0 && usname!=null){
			ulist = ubiz.getUseridAndUsername(usid, usname);
		}else if(depart!=null){
			ulist = ubiz.getByProperty(Userinfo.class, "departid", depart);
			
		}else if(usid!=0){
			ulist = ubiz.getByProperty(Userinfo.class, "userid", usid);
			
		}else if(usname!=null){
			ulist = ubiz.getByPorUsername(usname);
			
		}else{
			ulist = ubiz.getAll(Userinfo.class);
		}
		session.put("ulist", ulist);
		return SUCCESS;
	}
	
	
	public void setSession(Map<String, Object> arg0) {
		this.session=arg0;
	}

	public String getDepart() {
		return depart;
	}

	public void setDepart(String depart) {
		this.depart = depart;
	}

	public long getUsid() {
		return usid;
	}

	public void setUsid(long usid) {
		this.usid = usid;
	}


	public String getUsname() {
		return usname;
	}

	public void setUsname(String usname) {
		this.usname = usname;
	}

	public String getUserresult() {
		return userresult;
	}

	public void setUserresult(String userresult) {
		this.userresult = userresult;
	}

	public UserInfoBiz getUbiz() {
		return ubiz;
	}
	
	public void setUbiz(UserInfoBiz ubiz) {
		this.ubiz = ubiz;
	}

	
}
